package thread;

class TicketTask implements Runnable{
    static int count = 1000;
    @Override
    public void run() {
        while (true){
            synchronized (this) {
                if (count <= 0) break;
                System.out.println(Thread.currentThread().getName() + "买了第" + count + "张票");
                count--;
            }
        }
    }
}

public class TreadPriorityDemo01 {
    public static void main(String[] args) {
        TicketTask ticketTask = new TicketTask();
        Thread thread1 = new Thread(ticketTask,"窗口1");
        Thread thread2 = new Thread(ticketTask,"窗口2");
        Thread thread3 = new Thread(ticketTask,"窗口3");



        thread1.start();
        thread2.start();
        thread3.start();


    }
}
